package com.squid.base.common.error;

import lombok.extern.slf4j.Slf4j;

/**
 * Description
 *
 * @author jinhang
 * @since 2024-1-23
 **/
@Slf4j
public class ExceptionFactory {
    public static ServerException instanceServerException(Integer code, String message) {
        log.error("{}", message);
        return new ServerException(code, message);
    }

    public static ServerException instanceServerException(String message) {
        log.error("{}", message);
        return new ServerException(SystemCodeMsgEnums.ERROR.getCode(), message);
    }

    public static ServerException instanceServerException(String message, Exception e) {
        log.error("{}", message, e);
        return new ServerException(SystemCodeMsgEnums.ERROR.getCode(), message);
    }

    public static ServerException instanceServerException(String message, Throwable e) {
        log.error("{}", message, e);
        return new ServerException(SystemCodeMsgEnums.ERROR.getCode(), message);
    }
    public static ServerException instanceServerException(BaseErrorCodeMsg enums) {
        log.error("{}", enums.getMessage());
        return new ServerException(enums.getCode(), enums.getMessage());
    }

    public static ServerException instanceServerException(BaseErrorCodeMsg enums, Exception e) {
        log.error("{}", enums.getMessage(), e);
        return new ServerException(enums.getCode(), enums.getMessage());
    }
    public static BusinessException instanceBusinessException(Integer code, String message) {
        log.error("{}", message);
        return new BusinessException(code, message);
    }

    public static BusinessException instanceBusinessException(String message) {
        log.error("{}", message);
        return new BusinessException(SystemCodeMsgEnums.ERROR.getCode(), message);
    }

    public static BusinessException instanceBusinessException(BaseErrorCodeMsg enums) {
        log.error("{}", enums.getMessage());
        return new BusinessException(enums.getCode(), enums.getMessage());
    }

    public static BusinessException instanceBusinessException(BaseErrorCodeMsg enums, Exception e) {
        log.error("{}", enums.getMessage(), e);
        return new BusinessException(enums.getCode(), enums.getMessage());
    }

    public static BusinessException instanceBusinessException(BaseErrorCodeMsg enums, Throwable e) {
        log.error("{}", enums.getMessage(), e);
        return new BusinessException(enums.getCode(), enums.getMessage());
    }
}
